package com.bfly.mall.product.dto;

import com.alibaba.fastjson.annotation.JSONField;
import com.bfly.mall.product.enums.PricingMethodEnum;
import com.bfly.mall.product.enums.ShippingMethodEnum;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 运费模板计价方式列表DTO
 *
 * @author 长沙商脉科技有限公司
 * @date 2020/4/27 10:49
 */
public class FreightTemplatePricingListDTO implements Serializable {

    private static final long serialVersionUID = -3977362078171757921L;
    private int shippingMethod;
    private String cityNames;

    @JSONField(serialize = false)
    private int firstPiece;
    @JSONField(serialize = false)
    private int nextPiece;
    @JSONField(serialize = false)
    private BigDecimal firstWeight;
    @JSONField(serialize = false)
    private BigDecimal nextWeight;
    @JSONField(serialize = false)
    private BigDecimal firstVolume;
    @JSONField(serialize = false)
    private BigDecimal nextVolume;

    // 根据计价方式显示单位和首件续件
    @JSONField(serialize = false)
    private int pricingMethod;

    private BigDecimal firstPrice;
    private BigDecimal nextPrice;
    private boolean defaults;

    public String getShippingMethodName() {
        ShippingMethodEnum methodEnum = ShippingMethodEnum.getShippingMethod(getShippingMethod());
        return methodEnum == null ? "" : methodEnum.getName();
    }

    /**
     * 首件，首重，首体积购买数
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/10/9 21:33
     */
    public String getFirstNum() {
        PricingMethodEnum methodEnum = PricingMethodEnum.getPricingMethod(getPricingMethod());
        switch (methodEnum) {
            case PIECE:
                return getFirstPiece() + "";
            case MONEY:
                return getFirstPrice() + "";
            case WEIGHT:
                return getFirstWeight() + "";
            case VOLUME:
                return getFirstVolume() + "";
            default:
                return "";
        }
    }

    /**
     * 续件，续重，续体积购买数
     *
     * @author 长沙商脉科技有限公司
     * @date 2020/10/9 21:35
     */
    public String getNextNum() {
        PricingMethodEnum methodEnum = PricingMethodEnum.getPricingMethod(getPricingMethod());
        switch (methodEnum) {
            case PIECE:
                return getNextPiece() + "";
            case MONEY:
                return getNextPrice() + "";
            case WEIGHT:
                return getNextWeight() + "";
            case VOLUME:
                return getNextVolume() + "";
            default:
                return "";
        }
    }

    public String getCityNames() {
        return cityNames;
    }

    public void setCityNames(String cityNames) {
        this.cityNames = cityNames;
    }


    public boolean isDefaults() {
        return defaults;
    }

    public void setDefaults(boolean defaults) {
        this.defaults = defaults;
    }

    public int getPricingMethod() {
        return pricingMethod;
    }

    public void setPricingMethod(int pricingMethod) {
        this.pricingMethod = pricingMethod;
    }

    public int getShippingMethod() {
        return shippingMethod;
    }

    public void setShippingMethod(int shippingMethod) {
        this.shippingMethod = shippingMethod;
    }

    public int getFirstPiece() {
        return firstPiece;
    }

    public void setFirstPiece(int firstPiece) {
        this.firstPiece = firstPiece;
    }

    public int getNextPiece() {
        return nextPiece;
    }

    public void setNextPiece(int nextPiece) {
        this.nextPiece = nextPiece;
    }

    public BigDecimal getFirstWeight() {
        return firstWeight;
    }

    public void setFirstWeight(BigDecimal firstWeight) {
        this.firstWeight = firstWeight;
    }

    public BigDecimal getNextWeight() {
        return nextWeight;
    }

    public void setNextWeight(BigDecimal nextWeight) {
        this.nextWeight = nextWeight;
    }

    public BigDecimal getFirstVolume() {
        return firstVolume;
    }

    public void setFirstVolume(BigDecimal firstVolume) {
        this.firstVolume = firstVolume;
    }

    public BigDecimal getNextVolume() {
        return nextVolume;
    }

    public void setNextVolume(BigDecimal nextVolume) {
        this.nextVolume = nextVolume;
    }

    public BigDecimal getFirstPrice() {
        return firstPrice;
    }

    public void setFirstPrice(BigDecimal firstPrice) {
        this.firstPrice = firstPrice;
    }

    public BigDecimal getNextPrice() {
        return nextPrice;
    }

    public void setNextPrice(BigDecimal nextPrice) {
        this.nextPrice = nextPrice;
    }
}
